Component({
  behaviors: [],
  properties: {},
  data: {
    tabbars: {
      // tabbar所有的子项
      list: [{
        pagePath: "/pages/index/index",
        text: "首页",
        icon: "home-o"
      }, {
        pagePath: "/pages/historical-failure/index",
        text: "历史故障",
        icon: "notes-o"
      },{
        pagePath: "/pages/home/index",
        text: "个人中心",
        icon: "user-circle-o"
      }],
      // 当前活跃的tabbar子项
      active: 0,
    },
  },
  lifetimes: {},
  methods: {
    onChange(e) {
      wx.switchTab({
        url: this.data.tabbars.list[e.detail].pagePath
      });
    },
    init() {
      const page = getCurrentPages().pop();
      this.setData({
        selected: this.data.list.findIndex(item => item.url === `/${page.route}`)
      });
    },
  }
})